
#include "AnimalFactory.h"
#include "Grass.h"
#include "ReflexDeflex.h"
#include "Map.h"
class GrassFactory :
	public AnimalFactory
{
public:
	GrassFactory();
	~GrassFactory();

	static Animal* getGrass() {
		Map* cMap = Map::getInstanceCMap();

		XY* xy = new XY(rand() % MAPX, rand() % MAPY);
		while (cMap->getLocationMap(xy) != nullptr)
			xy = new XY(rand() % MAPX, rand() % MAPY);
		Animal* animal = new Grass();
		animal->setName('G');
		animal->setAge(0);
		animal->setLifeTime(50);
		animal->setHunger(10);
		animal->setLocation(xy);
		animal->setReproduceFlag(true);
		if (rand() % 2 == 0)
			animal->setSex(true);
		else animal->setSex(false);

		cMap->setLocationMap(animal, xy);

		return animal;
	}
	static void createGrass() {
		AnimalFactory* animalFactory = AnimalFactory::getAnimalFactory();
		animalFactory->resiger("Grass", GrassFactory::getGrass);
	};
};
